﻿using SPCAM.Plugin.Cam.ViewModel;
using SPCAM.Servers;
using SPCAM.Utils;
using SPCAM.Views;

namespace SPCAM.Plugin.Cam
{
    public class CamPlugin : IPlugin
    {

        public  IServer server{get; set ;}
        private CamViewModel Vm;
        private static CamPlugin _caminstance;
        public static CamPlugin Instance { get=> _caminstance; }
        public CamHeader MainHander { get; set; }
        public CamPlugin()
        {
            _caminstance = this;
        }

        public void Init(IServer spview)
        {
            server = spview;
            Vm = new CamViewModel(spview);
            MainHander = new CamHeader();
        }

        public bool Startup()
        {
            var headitml = new  RibonHeadItem();
            headitml.TabItem = MainHander; 
            var img = Utils.Tools.PathToImg("/SpCam.Resources;component/icon/Cam.png");

            headitml.Button = new Fluent.Button
            {
                Header = "Cam",
                Icon = img,
            };
            headitml.Datacontext = Vm;
            headitml.Color=new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Green);
            headitml.isShow = true;
            server.RibbonHeader.Addheader(headitml);
            return true;
        }
    }
}
